const mysql =  require('mysql')
const connection = mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'12345678',
    database:'test1'
})
connection.connect();
// connection.query("update stu set name = 'bb' where id = 6", function (error, results, fields) {
//   if (error) throw error; //JS语法抛出异常
//   console.log('The solution is: ', results);
// });
exports.mysql = (sql)=>{
    const promise = new Promise( (resolve, reject)=>{
        connection.query(sql,function (error,results,fields){
            if(error) reject(error) // 数据处理错误
            resolve(results) // 数据处理完成
        })
    })
    return promise
}
